<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>title</title>
    <script type="text/javascript" src="../script/config.js"></script>
    <style>
    body{
     background-color:white;
    }
        .scheduling_a{
          margin:1.5rem;
          /*height:170px;*/
        }
        .scheduling_a_id_a{
          width:100%;
          /*height:40px;*/
          font-size:16px;
        }

        .scheduling_id{
            width:100%;
          color:#f16c3c;
        }
        .scheduling_name{
          height:30px;
          margin-top:10px;
          line-height:30px;
        }
        .scheduling_name,.scheduling_address,.scheduling_phone,.scheduling_to{
          line-height:30px;
        }
        .scheduling_to{
        color:#f16c3c;
        }
        .scheduling_line{
          height:0;
          width:100%;
          border-top:1px solid #d2d2d2;
          margin-top:10px;
        }
    </style>
</head>
<body>
    <!-- <div id="wrap" class="flex-wrap flex-vertical" >
        <header class="border-b" >
            <b tapmode="hover" onclick="api.closeWin();" class="ic-back"></b>
            <div class="title">历史单据</div>
          b tapmode="hover" onclick="funActionSheet();"  class="ic-check"></b>
        </header>
        <div id="main" class="flex-con" > -->
        <!-- <div class="scheduling_a">
           <div class="scheduling_a_id_a">
              <div class="scheduling_id">
                 清单号:<span>11280874598</span>

              </div>
              <div class="scheduling_to">
                <span style="padding-left:2rem;">南京</span>
                <img src="../image/arrows.png" style="width:10%;"/>
                <span>南通</span>
              </div>
              <div class="scheduling_name">
                收货单位/人：李二
              </div>
              <div class="scheduling_phone">
                联系电话：15862790779
              </div>
              <div class="scheduling_address">
                地址：武汉市
              </div>
              <div class="scheduling_line"></div>
           </div>
        </div>
        <div class="scheduling_a">
           <div class="scheduling_a_id_a">
              <div class="scheduling_id">
                 清单号:<span>11280874598</span>
              </div>
              <div class="scheduling_to">
                <span style="">南京</span>
                <img src="../image/arrows.png" style="width:10%;"/>
                <span>南通</span>
              </div>
              <div class="scheduling_name">
                收货单位/人：李二
              </div>
              <div class="scheduling_phone">
                联系电话：15862790779
              </div>
              <div class="scheduling_address">
                地址：武汉市
              </div>
              <div class="scheduling_line"></div>
           </div>
        </div> -->
        <!-- </div>
    </div> -->
</body>
</html>
<script type="text/javascript" src="../script/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="../script/api.js"></script>
<!-- <script type="text/javascript" src="../script/up_check.js"></script> -->
<script type="text/javascript">
    apiready = function(){
      var user = $api.getStorage('user');
      var lorryid=user.lorryid;
      var telephone=user.telephone;
      var time=user.time;
      // alert(user.lorryid)
         $api.get(url+'app.php/schistory?lorry_id='+lorryid,function(ret){
     							if(ret.result==0){
                    api.toast({
                       msg: '成功',
                       duration: 1000,
                      location: 'middle'
                    });
                                  for(var i=0;i<ret.schedules.length;i++){
                                    $api.append($api.dom('body'),'<div class="scheduling_a" id="'+ret.schedules[i].scheduling_id+'">'+
                                                   '<div class="scheduling_a_id_a">'+
                                                      '<div class="scheduling_id">'+
                                                         '清单号:<span>'+ret.schedules[i].scheduling_id+'</span>'+
                                                      '</div>'+
                                                      '<div class="scheduling_to">'+
                                                      '<span>'+ret.schedules[i].sendcity+'</span>'+
                                                      '<img src="../image/arrows.png" style="width:10%;"/>'+
                                                      '<span>'+ret.schedules[i].receivecity+'</span>'+
                                                      '</div>'+
                                                      '<div class="scheduling_name">'+"收货单位/人："+ret.schedules[i].customer_name+'</div>'+
                                                      '<div class="scheduling_phone">'+"联系电话："+ret.schedules[i].customer_phone+'</div>'+
                                                      '<div class="scheduling_address">'+"地址："+ret.schedules[i].address+'</div>'+
                                                      '<div class="scheduling_status">'+"状态："+'<span id="q'+ret.schedules[i].scheduling_id+'"></span></div>'+
                                                      '<div class="scheduling_line"></div>'+
                                                   '</div>'+
                                                '</div>');
                                          $api.addEvt($api.dom('#'+ret.schedules[i].scheduling_id), 'click',function(){
                                            var scheduling_id=$api.attr(this,'id');
                                            api.openWin({
                                                name: 'history_main',
                                                url: './history_main.html',
                                                pageParam: {
                                                    scheduling_id: scheduling_id,
                                               }
                                            });
                                            check(lorryid,time);
                                          });
                                       if(ret.schedules[i].scheduling_status==5){
                                         $api.text($api.dom('#q'+ret.schedules[i].scheduling_id),'签收');
                                         $api.css($api.dom('#q'+ret.schedules[i].scheduling_id),'color:rgb(23,139,23);');
                                       }else if(ret.schedules[i].scheduling_status==6){
                                         $api.text($api.dom('#q'+ret.schedules[i].scheduling_id),'退单中');
                                         $api.css($api.dom('#q'+ret.schedules[i].scheduling_id),'color:#1818FF;');
                                       }else if(ret.schedules[i].scheduling_status==7){
                                         $api.text($api.dom('#q'+ret.schedules[i].scheduling_id),'退单成功');
                                         $api.css($api.dom('#q'+ret.schedules[i].scheduling_id),'color:#1818FF;');
                                       }else{
                                         $api.text($api.dom('#q'+ret.schedules[i].scheduling_id),'出险');
                                         $api.css($api.dom('#q'+ret.schedules[i].scheduling_id),'color:red;');
                                       }
                                  }
     														 }else{
     															 alert(ret.desc);
     														 }
                            },'json');

                  };
                  var check=function(id,time){
                    $api.post(url+'app.php/check',{
                          body:{lorryid:id,
                                time:time,}
                         },function(ret){
                          if(ret.result==4){
                            alert(ret.desc);
                            api.openWin({
                              name: 'index',
                              url:  '../index.html',
                            });
                             setTimeout("api.closeWin({name:'main'})",650);
                             $api.rmStorage('password');
                             var key = 'user';
                             var user = {};
                             var aa=$api.getStorage(key);
                             user.lorryid=aa.lorryid;
                              user.telephone=aa.telephone;
                             user.flag= aa.flag
                             user.pass= '';
                             $api.setStorage(key, user);
                             api.alert({
                               title: '提示消息',
                               msg: ret.desc,
                               buttons: ['确定']
                             });
                           }else{
                            //  alert(ret.desc);
                           }
                         });
                  }


</script>
